using System;
using System.ComponentModel.Composition;
using System.IO;


namespace Yammu.Core.VirtualFileSystem
{
    /// <summary>
    /// Provides access to the local file system
    /// </summary>
        [MVFSProviderExport(MVPProviderType.Local)]
    public sealed class LocalVFSProvider : VFSProviderBase<LocalVirtualFile, LocalVirtualDirectory,
            VFSProviderConfigurationBase, VFSProviderCredentialsBase>
        {

		    public LocalVFSProvider () 
		    {
		    }

            public override void Initialize(IVFSProviderConfiguration config, IVFSProviderCredentials credentials)
		    {
               base.Initialize(config, credentials);
		    }

	        public override string CombineVirtualPaths(string basePath, string relativePath)
	        {
	            return Path.Combine(basePath, relativePath);
	        }


		    public override bool DirectoryExists (string virtualDir)
		    {
                return Directory.Exists(virtualDir);
		    }

		    public override bool FileExists (string virtualPath)
		    {

                return File.Exists(virtualPath);
		    }

	
		    public override IVFSItem GetDirectory (string virtualDir)
		    {
			    if (virtualDir == null || virtualDir == "")
				    throw new ArgumentNullException ("virtualDir");

			    return new LocalVirtualDirectory (virtualDir);
		    }

		    public override IVFSItem GetFile (string virtualPath)
		    {
			    if (virtualPath == null || virtualPath == "")
				    throw new ArgumentNullException ("virtualPath");

			    return new LocalVirtualFile (virtualPath);
		    }

		    public override string GetFileHash (string virtualPath)
		    {
			    if (virtualPath == null )
				    throw new NullReferenceException ();
                //@tbd
			    return virtualPath;
		    }

	        public  override IVFSItem GetRoot(IVFSItem entry)
	        {

              return new LocalVirtualDirectory(null);
	        }
        }
}


